package ee.greaton.kultuuriaken;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;

import android.util.Log;

class EventList {
	private LinkedList<Event> eventList = new LinkedList<Event>();

	public void add(Event e) {
		eventList.add(e);
	}

	public void clear() {
		eventList.clear();
	}

	public int size() {
		return eventList.size();
	}

	public Iterator<Event> iterator() {
		return eventList.iterator();
	}

	public Event get(int i) {
		return eventList.get(i);
	}

	public ArrayList<Event> getAllEvents() {
		ArrayList<Event> res = new ArrayList<Event>();
			for (Event e : eventList) {
				res.add(e);
			}
		return res;
	}
	
	public void addAll(ArrayList<Event> list){
		eventList.addAll(list);
	}
	
	public Event getLast(){
		int size = eventList.size() - 1;
		Event e;
		while(true){
			e = eventList.get(size);
			if(!e.getDate().equals("")){
				break;
			}
			size--;
			if(size == -1){
				break;
			}
		}
		return e;
	}
}
